const reg_containerStr = /[.#][\w$]+/;

/**
 * 根据
 *
 * any_str
 *
 * .class #id
 *
 * HTMLElement
 *
 * 尝试 找寻 到 HTMLElement
 * @param  container
 * @param  ignore 忽略未查询到 反馈信息 默认 false 打印  | true 不打印
 */
export function normalizeContainer(
  container: HTMLElement | string,
  ignore: boolean = false
) {
  if (typeof container == 'string') {
    let res: HTMLElement | null;
    if (!container.match(reg_containerStr)) {
      res = document.getElementById(container);
      if (res) {
        return res;
      }
    }
    res = document.querySelector(container);

    if (res == null) {
      if (!ignore) {
        throw new Error(`sorry your container not find : ${container} `);
        // console.log('sorry your container not find :', container);
      }
    }
    return res;
  }
  return container;
}
